<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="me.yobol.greentable.commons.path.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>Create Dishes</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
  	<%
  		String msg = (String)request.getParameter("msg");
  		if(msg != null)
		{
			
			//当msg不为空时，说明用户以forward转发方式跳转过来
			//..还是代表的请求重定向发起者——CreateDishesServlet.java文件
			//所以以../ckeditor/ckeditor.js方式便获取不到ckeditor.js文件
			if(msg.equals("DishesNameDuplication"))
			{
	%>
				<script type="text/javascript" src="<%=request.getContextPath() %>/ckfinder/ckfinder.js"></script>
				<script type="text/javascript" src="<%=request.getContextPath() %>/ckeditor/ckeditor.js"></script>
				<script>
					alert("已经发布过此菜谱");
				</script>
	<%
			}
		}else{
				//查看Chrome Console可以发现症结所在
	%>
				<script type="text/javascript" src="../ckfinder/ckfinder.js"></script>
				<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
	<%
		}
	%>
  	<form action="<%=SPath.sCreateDishes(request) %>" method="post">
  		<input type="text" name="dishesName" placeholder="菜谱名" />
  		<input name="dishesDescription" placeholder="菜谱描述"/>
		<input type="submit" value="发布菜谱" />
  		<input type="hidden" name="menuId" value="2">
		<textarea id="dishes_content" name="dishesContent" rows="10" cols="80" >
		</textarea>
		<script>
			// Replace the <textarea id="editor1"> with a CKEditor
			// instance, using default configuration.
			var editor = CKEDITOR.replace("dishes_content");
			CKFinder.setupCKEditor(editor, "../ckfinder/") ;
		</script>
	</form>
  </body>
</html>
